package cz.incad.psh.pshassign.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
import static com.google.gwt.query.client.GQuery.$;
import com.google.gwt.user.client.DOM;
import static gwtquery.plugins.ui.Ui.Ui;

/**
 *
 * @author alberto
 */
public class Header extends Composite {

    private static HeaderUiBinder uiBinder = GWT.create(HeaderUiBinder.class);



    interface HeaderUiBinder extends UiBinder<Widget, Header> {
    }
    
    @UiField
    Anchor optionsBt;

    @UiField
    Anchor adminBt;
    
    @UiField
    Admin menu;
    
    @UiField
    Options options;
    
    private void init() {
        initWidget(uiBinder.createAndBindUi(this));
        
        
        adminBt.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                menu.show();
                event.stopPropagation();
                DOM.eventCancelBubble(DOM.eventGetCurrentEvent(), true); 
            }
        });
        
        
        
        optionsBt.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                options.load();
                $("#options").as(Ui).dialog("{width:800, height: 480}");
            }
        });

    }
    
    public void hideAdmin(){
        menu.hide();
    }
    
    public Header() {
        init();
    }
    
    @Override
    protected void onLoad(){
        
        
    }
}
